<extend name="Index/index"/>

<block name="register">
    <form action="{{:U('User/commitOrder')}}" method="post">
        <input type="hidden" name="act" value="{{$act}}">
        <div class="container mt30">
            <div class="row address" >
                <h3><b>确认收货地址</b></h3>
                <span class="btn btn-primary" onclick="addAddress()">新建地址</span>
                <br><br>
                <div class="form-group" style="display: none" id="addAddress">
                    <div class="col-lg-3">
                        联系人:&nbsp;&nbsp;&nbsp;<input type="text" id="name">
                    </div>
                    <div class="col-lg-3">
                        手机号:&nbsp;&nbsp;&nbsp;<input type="number" id="tel">
                    </div>
                    <div class="col-lg-2">
                        <span class="btn btn-primary" onclick="add()">提交</span>
                    </div>
                    <br><br>
                    <div class="col-lg-8">
                        <textarea name="msg"  class="form-control" rows="3" id="address"></textarea>
                    </div>


                </div>
                <div id="newaddress">
                </div>
            </div>
        </div>
        <div class="container">

            <div class="row mt10 address">
                <h3><b>确认订单信息</b></h3>
            </div>

            <div class="row col-md-12 mt30">

                <table class="row col-md-12 text-center table" cellpadding="0" cellspacing="0">
                    <tr>
                        <th class="text-center">商品图片</th>
                        <th class="text-center">商品名称</th>
                        <th class="text-center">商品价格</th>
                        <th class="text-center">商品数量</th>
                        <th class="text-center">小计</th>
                    </tr>

                    <foreach name="orderList" item="item">
                        <tr>
                            <!--商品id-->
                            <input type="hidden" name="goods_id{{$item.id}}" value="{{$item.id}}">
                            <input type="hidden" name="goods_num{{$item.id}}" value="{{$item.num}}">

                            <!--商品图片-->
                            <td class="col-md-2">
                                <a href="{{:U('Index/goodsDetails',array('id'=>$item['id']))}}">
                                    <img src="{{:get_img_url('__ROOT__/Uploads/GoodsImg/',$item['img'],50)}}">
                                </a>
                            </td>
                            <!--商品名称-->
                            <td class="col-md-2">
                                <a href="{{:U('Index/goodsDetails',array('id'=>$item['id']))}}">
                                    {{:subtext($item['goods_name'],20)}}
                                </a>
                            </td>
                            <!--商品价格-->
                            <td class="col-md-1">
                                <span class="glyphicon glyphicon-jpy" style="font-size: 20px;color: red;"></span>
                                <span id="price{{$item.id}}" style="font-size: 15px;color: red">{{$item.price}}</span>
                            </td>
                            <!--商品库存-->
                            <input type="hidden" id="num{{$item.id}}" value="{{$item.goods_num}}">
                            <!--商品数量-->
                            <td class="col-md-2">
                                <span style="font-size: 20px;">{{$item.num}}</span>
                            </td>
                            <!--商品小计-->
                            <td class="col-md-2">
                                <span class="glyphicon glyphicon-jpy" style="font-size: 20px;color: red;"></span>
                                <span id="total{{$item.id}}" style="font-size: 15px;color: red" class="order_{{$item.id}}">{{$item['num']*$item['price']}}</span>
                            </td>
                        </tr>
                    </foreach>

                    <eq name="$orderList[0]['goods_type']" value="0">
                        <!--优惠券使用-->
                        <tr>
                            <td colspan="5" class="text-right">
                                <span style="font-size: 20px">
                                    优惠券:
                                <empty name="empty($couponList)">
                                    <select name="coupon_id">
                                        <option value="0">无可用的优惠券</option>
                                    </select>
                                    <else/>
                                    <select name="coupon_id" onclick="changeTotal()">
                                        <!--优惠券按照使用的最小价格,从低到高排列
                                        如果应付金额比最小都小,则无可用的优惠券-->
                                        <gt name="$couponList[0]['min_pri']" value=$sum">
                                            <option value="0">无可用的优惠券</option>
                                            <else/>
                                            <option value="0">有可用的优惠券</option>
                                            <foreach name="couponList" item="value">
                                                <!--判断应付金额是否比优惠券的最小使用价格大-->
                                                <elt name="$value['min_pri']" value="$sum">
                                                    <option value="{{$value.cou_pri}}">{{$value.name}}</option>
                                                </elt>
                                            </foreach>
                                        </gt>

                                    </select>
                                </empty>
                                </span>

                            </td>
                        </tr>
                        <!--积分使用-->
                        <tr>
                            <td colspan="5" class="text-right">
                                <span style="font-size: 20px">
                                    <if condition="empty($integralInfo['num'])">
                                        积分:您的积分已用完!!!
                                        <else/>
                                        积分:您一共有 <span style="color: red;font-size: 20px" id="integralNum">{{$integralInfo.num}}</span> 积分 可抵扣 <span style="color: red;font-size: 20px" id="integralPrice"></span> 元 是否抵扣
                                        <input type="radio" value="0" name="inte" onclick="changeTotalByinte()">否
                                        <input type="radio" value="1" name="inte" checked onclick="changeTotalByinte()">是

                                    </if>
                                </span>

                            </td>
                        </tr>
                        <else /> value3
                    </eq>

                    <tr>
                        <td colspan="3" class="text-right">
                            <span style="font-size: 15px" class="text-danger">应付金额:</span>
                        </td>
                        <td colspan="1">
                            <span class="glyphicon glyphicon-jpy text-danger" style="font-size: 25px;"></span>
                            <span style="font-size: 15px;font-weight: bold" class="text-danger" id="total_price">0</span>
                            <span style="display: none"  id="total_price_true">{{$sum}}</span>
                            <span style="font-size: 15px;font-weight: bold" class="text-danger" >元</span>
                        </td>
                        <td colspan="1" class="text-right">

                            <button class="btn btn-danger" type="submit">确认订单</button>

                        </td>
                    </tr>
                </table>

            </div>

        </div>
    </form>
    <script src="__PUBLIC__/Home/js/home.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/home.css">
    <script>
        showAddress();
        totalPrice();
        changeIntegral();
        changeTotalByinte()
    </script>
</block>